package socketmvc.client.config;

import socketmvc.core.codec.IPacketCodec;
import socketmvc.core.codec.ProtocolCodecHandler;
import socketmvc.core.config.SocketMvcConfig;
import socketmvc.core.filter.FilterHandler;
import socketmvc.core.filter.IFilter;
import socketmvc.core.processor.ProcessorMethodHandler;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class DefMvcConfig implements SocketMvcConfig {

    private ProcessorMethodHandler methodHandler;
    private ProtocolCodecHandler codecHandler;
    private FilterHandler filterHandler;
    private IpConfig ipConfig;
    Set<String> scanPackage;

    public DefMvcConfig() {
       this(null);
    }

    public DefMvcConfig(IpConfig ipConfig) {
        this.methodHandler = new ProcessorMethodHandler();
        this.codecHandler =  new ProtocolCodecHandler();
        this.filterHandler = new FilterHandler();
        this.scanPackage = new HashSet<>();
        this.ipConfig = ipConfig;
    }

    @Override
    public IpConfig getIpConfig() {
        return ipConfig;
    }

    /**
     * 获取扫描处理器的包路径
     *
     * @return 包路径
     */
    @Override
    public Set<String> getProcessorScanPackage() {
        return scanPackage;
    }

    /**
     * 获取过滤器
     *
     * @return Filters
     */
    @Override
    public Collection<IFilter> getFilters() {
        return null;
    }

    /**
     * 获取数据包编解码器
     *
     * @return Codecs
     */
    @Override
    public Collection<IPacketCodec> getPacketCodecs() {
        return null;
    }

    /**
     * 获取mvc方法映射处理器(处理类方法和注解的mvc路径的对应关系以及其参数类型映射等等)
     *
     * @return ProcessorMethodHandler
     */
    @Override
    public ProcessorMethodHandler getProcessorMethodHandler() {
        return methodHandler;
    }

    /**
     * 获取报文的协议编解码器
     *
     * @return ProtocolCodecHandler
     */
    @Override
    public ProtocolCodecHandler getProtocolCodecHandler() {
        return codecHandler;
    }

    /**
     * 获取mvc过滤器
     *
     * @return ProtocolCodecHandler
     */
    @Override
    public FilterHandler getFilterHandler() {
        return filterHandler;
    }


    public void setIpConfig(IpConfig ipConfig) {
        this.ipConfig = ipConfig;
    }

    public void setMethodHandler(ProcessorMethodHandler methodHandler) {
        this.methodHandler = methodHandler;
    }

    public void setCodecHandler(ProtocolCodecHandler codecHandler) {
        this.codecHandler = codecHandler;
    }

    public void setFilterHandler(FilterHandler filterHandler) {
        this.filterHandler = filterHandler;
    }
}
